package co.edu.unal.bioingenium.kbmed.retrieval.data;

import co.edu.unal.bioingenium.kbmed.features.CollectionFeatures;
import co.edu.unal.bioingenium.kbmed.features.io.FeaturesIO;
import co.edu.unal.bioingenium.kbmed.text.index.io.InvertedIndexIO;
import co.edu.unal.bioingenium.kbmed.text.index.structures.InvertedIndexIntToInt;
import co.edu.unal.bioingenium.kbmed.text.index.structures.InvertedIndexStrToInt;
import co.edu.unal.bioingenium.kbmed.text.representation.io.CorpusIO;
import co.edu.unal.bioingenium.kbmed.text.representation.vo.Corpus;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Alejandro Riveros Cruz
 */
public class CollectionData {

    /**
     * 
     */
    private String collectionName;
    /**
     * 
     */
    private Corpus wordCorpus;
    /**
     * 
     */
    private CollectionFeatures wordsFeatures;
    /**
     * 
     */
    private InvertedIndexIntToInt wordByDocument;
    /**
     * 
     */
    private InvertedIndexStrToInt wordByNameIndex;
    /**
     * 
     */
    private InvertedIndexStrToInt metaByDocumentIndex;
    /**
     * 
     */
    private Corpus conceptCorpus;
    /**
     * 
     */
    private CollectionFeatures conceptsFeatures;
    /**
     * 
     */
    private InvertedIndexIntToInt conceptByDocument;

    /**
     * 
     * @param corpusName
     */
    public CollectionData(String corpusName) {
        wordCorpus = CorpusIO.loadCorpus(corpusName + "WordsCorpus.dat");
        if (wordCorpus != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} WordsCorpus successful", corpusName);
        }
        conceptCorpus = CorpusIO.loadCorpus(corpusName + "ConceptsCorpus.dat");
        if (conceptCorpus != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} ConceptsCorpus successful", corpusName);
        }
        wordsFeatures = FeaturesIO.loadCollectionFeatures(corpusName + "WordsFeatures.dat");
        if (wordsFeatures != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} WordsFeatures successful", corpusName);
        }
        conceptsFeatures = FeaturesIO.loadCollectionFeatures(corpusName + "ConceptsFeatures.dat");
        if (conceptsFeatures != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} ConceptsFeatures successful", corpusName);
        }
        wordByDocument = InvertedIndexIO.loadIntToIntInvertedIndex(corpusName + "WordsByDocument.idx");
        if (wordByDocument != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} WordsByDocument successful", corpusName);
        }
        conceptByDocument = InvertedIndexIO.loadIntToIntInvertedIndex(corpusName + "ConceptsByDocument.idx");
        if (conceptByDocument != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} ConceptsByDocument successful", corpusName);
        }
        wordByNameIndex = InvertedIndexIO.loadStrToIntInvertedIndex(corpusName + "WordsByName.idx");
        if (wordByNameIndex != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} WordsByName successful", corpusName);
        }
        metaByDocumentIndex = InvertedIndexIO.loadStrToIntInvertedIndex(corpusName + "MetaByDocument.idx");
        if (metaByDocumentIndex != null) {
            Logger.getLogger(CollectionData.class.getName()).log(Level.INFO, "Load {0} MetaByDocument successful", corpusName);
        }
    }

    /**
     * 
     * @return
     */
    public String getCollectionName() {
        return collectionName;
    }

    /**
     * 
     * @return
     */
    public InvertedIndexIntToInt getConceptByDocument() {
        return conceptByDocument;
    }

    /**
     * 
     * @return
     */
    public Corpus getConceptCorpus() {
        return conceptCorpus;
    }

    /**
     * 
     * @return
     */
    public CollectionFeatures getConceptsFeatures() {
        return conceptsFeatures;
    }

    /**
     * 
     * @return
     */
    public InvertedIndexStrToInt getMetaByDocumentIndex() {
        return metaByDocumentIndex;
    }

    /**
     * 
     * @return
     */
    public InvertedIndexIntToInt getWordByDocument() {
        return wordByDocument;
    }

    /**
     * 
     * @return
     */
    public InvertedIndexStrToInt getWordByNameIndex() {
        return wordByNameIndex;
    }

    /**
     * 
     * @return
     */
    public Corpus getWordCorpus() {
        return wordCorpus;
    }

    /**
     * 
     * @return
     */
    public CollectionFeatures getWordsFeatures() {
        return wordsFeatures;
    }
}
